<?php

namespace app\admin\controller;

class User extends UserBase
{
    public function update()
    {
        $model = \app\model\User::update(input());

        if ($roles = input('roles')) {
            $model = \app\model\User::find($model->id);
            $model->roles()->sync(array_column($roles, 'id'));
        }

        return json(['code' => 20000, 'msg' => '更新成功', 'data' => $model]);
    }
}
